package com.news.m;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.regex.Pattern;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.campus.utils.Http;


public class NewsRequestEngine extends AbNewsRequest{
public int id=10;
int page=1;
/**
 *新闻模块
 */
	
public static final String header="http://news.xaufe.edu.cn/";
	@Override
public 	ArrayList<NewsDAO> next() throws MalformedURLException, IOException {
		// TODO Auto-generated method stub
		 String url="http://news.xaufe.edu.cn/Class.asp?ID="+id+"&page="+page;

		//String s="http://news.xaufe.edu.cn/Class.asp?ID=10&page=3";
		// String header="http://news.xaufe.edu.cn";
		 ArrayList<NewsDAO>list=new ArrayList<NewsDAO>();
		// String url="http://news.xaufe.edu.cn/GetNews.asp";
		
		 Pattern p=Pattern.compile("<a href=(.*?) target=_blank title=(.*?)\"/");
		
			 Document doc=Jsoup.parse(Http.get(url,"GBK"));
			 Elements ele=doc.select("li[style=border-bottom:1px dashed #ccc;]");
			 for(org.jsoup.nodes.Element e:ele)
			 {
				// System.out.println(e);
				 System.out.println(e.select("span").text()); 
				 System.out.println(e.select("a").text());
				// System.out.print(WebViewUtils.handle(header+e.select("a").attr("href")));
				 System.out.println(header+e.select("a").attr("href"));
			   NewsDAO news=(new NewsDAO(e.select("a").text(),header+e.select("a").attr("href"),e.select("span").text()));
			
			 list.add(news);
			 }
			 
		page++;
		return list;
	}

}
